#ifndef INTEGRATOR_HPP
#define INTEGRATOR_HPP


namespace TermStructure
{
    //! A simple Simpson integrator
	template<typename TFunctor,typename T,typename TSize>
	T Integrator_simpson(T start,T end, TFunctor fx, TSize M = 1024)       //simpson rule
	{
		T result = 0;
		T h = (end-start)/M;
		for (TSize i=0;i<=M;i++)
		{
			result+=h*(fx(start+i*h)+4.0*fx(start+(i+0.5)*h)+fx(start+(i+1.0)*h))/6.0;
		}
		return result;
	}
}

#endif